package com.hziee.graduate.ticket.controller;



import com.hziee.graduate.ticket.dto.R;
import com.hziee.graduate.ticket.entity.Movie;
import com.hziee.graduate.ticket.service.MovieService;
import com.hziee.graduate.ticket.vo.ConditionMovieVO;
import com.hziee.graduate.ticket.vo.MovieChartVO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("movie")
public class MovieController {
    @Resource
    MovieService movieService;

    @PostMapping("/addMovie")
    public R<Object> addMovie(@RequestBody Map<String, String> map) {
        return movieService.addMovie(map);
    }

    @GetMapping("/getHotMovie/{locationName}")
    public R<List<Movie>> getHotMovie(@PathVariable String locationName) {
        return movieService.getHotMovie(locationName);
    }

    @GetMapping("/getLikeMovie/{locationName}/{userId}")
    public R<List<Movie>> getLikeMovie(
            @PathVariable("locationName") String locationName,
            @PathVariable("userId") Long userId)
    {
        return movieService.getLikeMovie(locationName,userId);
    }


    @GetMapping("/getAllMovieOrderByView/{locationName}")
    public R<List<Movie>> getLikeMovie(
            @PathVariable("locationName") String locationName)
    {
        return movieService.getAllMovieOrderByView(locationName);
    }

    @GetMapping("/getMovieById/{movieId}")
    public R<Movie> getMovieById(
            @PathVariable("movieId") Long movieId)
    {
        Movie movie = movieService.getBaseMapper().selectById(movieId);
        return R.success(movie);
    }

    @GetMapping("/getScheduledMovie/{locationName}/{date}")
    public R<List<Movie>> getScheduledMovie(
            @PathVariable("locationName") String locationName, @PathVariable("date")  String date)
    {
        return movieService.getScheduledMovie(locationName,date);
    }

    @PostMapping("/getMovieByCondition")
    public R<List<ConditionMovieVO>> getMovieByCondition(@RequestBody Map<String, String> map)
    {
        return movieService.getMovieByCondition(map);
    }

    @PostMapping("/getMovieByKeyword")
    public R<List<Movie>> getMovieByKeyword(@RequestBody ArrayList<String> keywords)
    {
        return movieService.getMovieByKeyword(keywords);
    }

    @PostMapping("/getMovieChart")
    public R<List<MovieChartVO>> getMovieChart(
            @RequestBody Map<String, Object> map
    ){
        return movieService.getMovieChart(map);
    }
}

